impl Solution {
    pub fn max_width_ramp(nums: Vec<i32>) -> i32 {
        let mut cache =vec!(-1 as i32;nums.len());
        for i in (0..nums.len()).rev(){
            Solution::max_dfs(&nums, i, &mut cache);
        }
        *cache.iter().max().unwrap()
    }
    fn max_dfs(nums: &[i32],i:usize,cache :&mut[i32])->i32{
        if i==0{
            return 0;
        }
        if cache[i]==-1{
            for j in 0..i{
                if nums[j]<=nums[i]{
                    cache[i]=(i-j) as i32+Solution::max_dfs(nums, j, cache);
                    break;
                }
            }
            if cache[i]==-1{
                cache[i]=0;
            }
        }
        cache[i]
    }
}